#!/usr/bin/python
#--*--coding:utf-8--*--
from lxml import etree
from io import BytesIO
#u很重要
tst=u'''<?xml version="1.0" encoding="utf-8"?>
 <employees>
 <employee>
 <name>xiaozhao</name>
 <sex>男</sex>
 <age>30</age>
 </employee>
 <employee>
 <name>zhao</name>
 <sex>女</sex>
 <age>12</age>
 </employee>
 </employees>'''
#解决中文解析的问题
for event,element in etree.iterparse(BytesIO(tst.encode('utf-8'))):
 print("%s, %s" % (element.tag, element.text))

 import re
 res=re.compile(r'(?<=<sex>)(.*?)(?=</sex>)')
 for i in re.findall(res,tst):
     print i
     
 
